/*
 * AgentContext.java
 *
 * Created on April 22, 2007, 9:30 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.xeerkat.agent;

import java.util.Iterator;
import java.util.concurrent.TimeUnit;
import org.restlet.Request;
import org.restlet.Uniform;
import org.restlet.data.Method;
import org.restlet.data.Protocol;
import org.restlet.data.Reference;
import org.xeerkat.agent.services.ServiceRuntime;
import org.xeerkat.xmpp.ID;

/**
 *
 * @author alex
 */
public interface AgentContext
{
   public final Protocol XMPP_PROTOCOL = Protocol.valueOf("xmpp");
   public final Protocol ASYNC_PROTOCOL = Protocol.valueOf("xeerkat");
   public final Protocol SYNC_PROTOCOL = Protocol.valueOf("sxeerkat");
   public final String AGENT_CONTEXT_ATTR = "org.xeerkat.attr.agent-context";

   boolean isOnline();

   boolean waitTillOnline(int time,TimeUnit units);
   
   ID getIdentity();
   
   AgentMonitor getAgentMonitor();
   
   TaskManager getTaskManager();
   
   Iterator<ServiceRuntime> getServices();

   Iterator<GroupChat> getChats();
   
   GroupChat joinChat(ID chatId,GroupChat.Listener listener)
      throws AgentException;

   GroupChat joinChat(ID chatId,String password,GroupChat.Listener listener)
      throws AgentException;

   void registerStanzaTarget(String id,Uniform target);
   
   void registerResponseListener(String id,ResponseListener listener);
   
   Reference createRequestReference(Protocol protocol,String to,String path);

   Request createRequest(Method method,Reference reference);

}
